import 'dart:convert';

import 'package:flutter/material.dart';
// import 'package:flutter_html/flutter_html.dart';
// import 'package:flutter_html/flutter_html.dart';
import 'package:nft_shop/widgets/my_app_bar.dart';
import 'package:nft_shop/widgets/my_scroll_view.dart';
import 'package:webview_flutter/webview_flutter.dart';
class AnnouncementPage extends StatelessWidget {
  late String title;
  late String content;
  late String url;
  WebViewController? _webViewController;
  AnnouncementPage({required this.title,required this.content});

  // @override
  // Widget build(BuildContext context) {
  //   return Scaffold(
  //     appBar: MyAppBar(
  //       centerTitle: title,
  //     ),
  //     body: MyScrollView(
  //         padding: EdgeInsets.all(10),
  //         children:[
  //           // Html(
  //           //   data: content,
  //           // ),
  //         ]
  //     ),
  //   );
  // }

  @override
  Widget build(BuildContext context) {
    print("标题-----${title}");
    print("标题-----${content}");
    return Scaffold(
        appBar: MyAppBar(
              centerTitle: title,
            ),
        body: WebView(
          initialUrl: '',
          javascriptMode: JavascriptMode.unrestricted,
          onWebViewCreated: (WebViewController webViewController) {
            _webViewController = webViewController;
            _loadHtmlFromAssets();
          },
        )
    );
  }

  _loadHtmlFromAssets() async {
    _webViewController!.loadUrl(Uri.dataFromString(content,
        mimeType: 'text/html', encoding: Encoding.getByName('utf-8'))
        .toString());
  }
}

